<html>
<head>
    <style>
        .box{
            position: relative;
            width: 200px;
            height: 200px;
            border: 1px solid gray;
        }
        @keyframes myfirst
        {
        0% {transform: rotate(15deg);transform-origin: top center;}
        /* 25% {transform: rotate(0deg);} */
        50% {transform: rotate(-15deg);transform-origin: top center;}
        /* 75% {transform: rotate(0deg);} */
        100% { transform: rotate(15deg);transform-origin: top center;}
        }
        .line{
            position: absolute;
            width: 15px;
            height: 100px;
            left: 50%;
            background: rebeccapurple;
            animation: myfirst 5s;
            animation-timing-function: linear;
            animation-iteration-count: infinite;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="line"></div>
    </div>
</body>
</html>